<?php


namespace app\controllers;


use app\models\request\ReqUserUpdate;
use app\service\SysUserRoleService;
use app\service\UserService;

class UserUpdateController extends BaseJsonController
{
    /**
     * @param $req ReqUserUpdate
     * @param $userInfo
     * @return mixed
     */
    public function doService($req, $userInfo)
    {

        $req->setCreateUserId($userInfo->getId());
        $userService = new UserService();
        $userId  = $userService->update($req);
        $userRoleService = new SysUserRoleService();
        $userRoleService->saveOrUpdate($userId,$req->getRoleIdList());
        return true;
    }


    protected function injectionReq()
    {
        return new ReqUserUpdate;
    }


    protected function permissionName()
    {
        return "sys/user/update";
    }

}